using System.Collections.Generic;
using UnityEngine;

namespace Voodoo.Sauce.Internal.DebugScreen
{
	public static class DebugLogTypes
	{
		private const string DEBUG_LOG_TYPES_KEY = "Voodoo_DebuggerLogTypes";

		private static readonly Dictionary<LogType, bool> EnabledLogTypes = new Dictionary<LogType, bool>
		{
			{
				LogType.Exception,
				true
			},
			{
				LogType.Error,
				true
			},
			{
				LogType.Warning,
				true
			}
		};

		private static bool _isInitialized = false;

		public static bool IsEnabled(LogType type)
		{
			Load();
			if (EnabledLogTypes.ContainsKey(type))
			{
				return EnabledLogTypes[type];
			}
			return false;
		}

		public static void Update(LogType type, bool isEnabled)
		{
			Load();
			EnabledLogTypes[type] = isEnabled;
			Save();
		}

		public static void Reset()
		{
			_isInitialized = false;
			EnabledLogTypes[LogType.Exception] = true;
			EnabledLogTypes[LogType.Error] = true;
			EnabledLogTypes[LogType.Warning] = true;
		}

		private static void Load()
		{
			if (!_isInitialized)
			{
				_isInitialized = true;
				int @int = NintendoPlayerPrefs.GetInt("Voodoo_DebuggerLogTypes", 7);
				EnabledLogTypes[LogType.Exception] = (@int & 1) == 1;
				EnabledLogTypes[LogType.Error] = ((@int >> 1) & 1) == 1;
				EnabledLogTypes[LogType.Warning] = ((@int >> 2) & 1) == 1;
			}
		}

		private static void Save()
		{
			int num = 0;
			if (EnabledLogTypes[LogType.Exception])
			{
				num |= 1;
			}
			if (EnabledLogTypes[LogType.Error])
			{
				num |= 2;
			}
			if (EnabledLogTypes[LogType.Warning])
			{
				num |= 4;
			}
			NintendoPlayerPrefs.SetInt("Voodoo_DebuggerLogTypes", num);
		}
	}
}
